USE NutritionTracker
GO
IF EXISTS (SELECT 1 FROM sysobjects WHERE ID = object_id(N'AppUser_AppRole_Update') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
	DROP PROCEDURE AppUser_AppRole_Update
GO
CREATE PROC AppUser_AppRole_Update
(
@AppUserID	INT.
@AppRoleList	NVARCHAR(4000)
)
AS
BEGIN
	SET NOCOUNT ON

	DELETE FROM		AppUser_AppRole
	WHERE		AppUserID = @AppUserID

	INSERT INTO		AppUser_AppRole
					(
					AppUserID,
					AppRoleID
					)
	SELECT		@AppUserID,
			CONVERT(INT,[Value])
	FROM		ListToTbl(@AppRoleList)

	SET NOCOUNT OFF
END
GO
GRANT EXECUTE ON AppUser_AppRole_Update TO NUTRKR_WEB
GO